import HttpClient from "../../../[框架]/网络/HttpClient";
import TaskProxy from "./TaskProxy";
let mockData = {
    "code": 0,
    "msg": "",
    "data": {
        "_id": "67943e05f08210ad572a384e",
        "game_name": "玩转水果",
        "game_appid": "wx5a40ccf5ddd4ff03",
        "sign_mode": 2,
        "is_force_click": 1,
        "force_click_count": 0,
        "force_click_time": "10",
        "force_click_percent": "0.95",
        "force_click_tips": "此次广告播放完毕以后,需点击广告下方<color=green>绿色按钮</color>进入广告体验8秒以后，然后退出即可完成任务",
        "normal_tips": "亲，需要您耐心观看一段视频完成签到以后才可以获得体力呢",
        "not_playover_tips": "亲，视频需要完整的播放以后才能获取到奖励呢",
        "not_clickad_tips": "亲，你没有体验广告，需要您播放完毕后<color=red>点击</color>绿色按钮点击广告进入体验页体验<color=white>8秒以后</color>才可以完成呢",
        "ad_play_error_tips": "当前没有合适您的视频观看，请稍后再试",
        "video_play_time": "30",
        "all_play_time": "60",
        "sign_need_look_times": 6,
        "reward_adunits": [{
            "_index": "jv5c3s6pd8laz10bpj5ko5274",
            "ad_unit": "adunit-0657adc24a4e00ce"
        }, {
            "_index": "rq4k3aoo5bbbhin4wcmpr3pdu",
            "ad_unit": "adunit-b2940b0d3c66850c"
        }, {
            "_index": "seupzxs9o3xl3li2t2y93lshj",
            "ad_unit": "adunit-c47646e46539c2c3"
        }, {
            "_index": "8s1akf12goiplu3e7thai3jk3",
            "ad_unit": "adunit-db0bcb024faa1172"
        }, {
            "_index": "c500rtn4srqv2nhke58o8542q",
            "ad_unit": "adunit-4d517c4930e59696"
        }, {
            "_index": "pae5c26ras1hu90szgkfvh2ow",
            "ad_unit": "adunit-7215559961464e02"
        }],
        "banner_adunits": "adunit-b662a178a1e501dc",
        "inset_adunits": "adunit-61c13c11c356e5bd",
        "_add_time": 1737768453151,
        "_add_time_str": "2025-01-25 09:27:33",
        "reward_task": [{
            "_index": "55xdb6zi66i03zu7unyo0ezt6",
            "ad_task_count": 6,
            "ad_task_name": "体力礼包"
        }, {
            "_index": "a7xkb9zi88i04zu9unyo1ezt8",
            "ad_task_count": 6,
            "ad_task_name": "每日任务"
        }, {
            "_index": "b8ykc1zi99i05zu2unyo2ezt9",
            "ad_task_count": 6,
            "ad_task_name": "金币礼包"
        }, {
            "_index": "c9zkd2zi11i06zu3unyo3ezt1",
            "ad_task_count": 6,
            "ad_task_name": "钻石礼包"
        }, {
            "_index": "d1zke3zi22i07zu4unyo4ezt2",
            "ad_task_count": 6,
            "ad_task_name": "道具礼包"
        }, {
            "_index": "e2zkf4zi33i08zu5unyo5ezt3",
            "ad_task_count": 6,
            "ad_task_name": "限时礼包"
        }, {
            "_index": "f3zkg5zi44i09zu6unyo6ezt4",
            "ad_task_count": 6,
            "ad_task_name": "特殊礼包"
        }],
        "countdown": "8",
        "interval_time": "广告冷却中"
    }
};
export default class TaskWeb {

    public static async getTaskConfig() {
        // return this.mock();
        let appId = Guyu.AdapterManager.adapter.appId || "wx5a40ccf5ddd4ff03";
        let xx = TaskProxy.inst;//触发缓存
        let url = `https://fc-mp-cd413cab-acc3-418e-8712-cf0ad3f2dfc2.next.bspapp.com/router/client/game.pub_find_Game`;
        let params = {
            game_appid: appId,
        }
        let res;
        try {
            res = await HttpClient.get(url, params);
        } catch (e) {
            Guyu.Log.error("获取任务配置失败===》", e);
            return Promise.resolve(false);
        }
        TaskProxy.inst.setData(res);
        return Promise.resolve(true);
    }

    public static async mock() {
        TaskProxy.inst.setData(mockData.data as any);
        return Promise.resolve(true);
    }
}